﻿USE master
GO

IF NOT EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'JML')
	CREATE DATABASE [JML]


if not exists (select * from dbo.syslogins where name = N'JML_User')
	EXEC sp_addlogin 'JML_User', 'password12'

if not exists (select * from dbo.syslogins where name = N'JMLbuildaccount')
	EXEC sp_addlogin 'JMLbuildaccount', 'JML01'



go


USE [JML]

if not exists (select * from dbo.sysusers where name = N'JML_User' and uid < 16382)
	EXEC sp_grantdbaccess N'JML_User', N'JML_User'


if not exists (select * from dbo.sysusers where name = N'JMLbuildaccount' and uid < 16382)
	EXEC sp_grantdbaccess N'JMLbuildaccount', N'JMLbuildaccount'


exec sp_addrolemember  @rolename = 'db_owner',  @membername = 'JMLbuildaccount' 



GO 